#include "myRect.h"
void Rect::WhereAmI()
{
	std::cout << "Now I am in class Rect" << std::endl;
}

void Rect::WhereAmIVirtual()
{
	std::cout << "Now I am in class Rect" << std::endl;
}

//����������� � ����������� ��� ������������� ���������� ������
Rect::Rect(int left, int right, int top, int bottom, colour col, bool contour, double transparency)
	:Shape(col,contour, transparency)
{	
	m_left = left;
	m_right = right;
	m_top = top;
	m_bottom = bottom;

	Standarting();
}
//����� "������������" ��������������
void Rect::Standarting()
{		
	if (m_right < m_left)
	{
		int tmp = m_right;
		m_right = m_left;
		m_left = tmp;
	}
	
	if (m_bottom < m_top)
	{
		int tmp = m_bottom;
		m_bottom = m_top;
		m_top = tmp;
	}		
}
void Rect::Inflate(int inflate)
{
	this->InflateRect(inflate / 2, inflate / 2, inflate / 2, inflate / 2);
}
//����� ������� ����������� ������� �������������� �� �������� ����������
void Rect::InflateRect(int left, int right, int top, int bottom)
{
	m_left -= left;
	m_right += right;
	m_top -= top;
	m_bottom += bottom;

	Standarting();	
}
//����� ������� ��������� ��� ���������, �� ��������� ������ 1
void Rect::InflateRect(int left, int right)
{
	m_left -= left;
	m_right += right;
	Standarting();
}

//����������� �����������
Rect::Rect(const Rect& other):Shape(other)
{
	m_left = other.m_left;
	m_right = other.m_right;
	m_top = other.m_top;
	m_bottom = other.m_bottom;
}
//����� ������� ����������� ���������� ������ ������������ ��������
void Rect::SetAll(int left, int right, int top, int bottom) 
{
	m_left = left;
	m_right = right;
	m_top = top;
	m_bottom = bottom;

	Standarting();
}

//����� ������� "�������" �������� private-���������� ������.
void Rect::GetAll(int& left, int& right, int& top, int& bottom) const
{
	left = m_left;
	right = m_right;
	top = m_top;
	bottom = m_bottom;
}

//����� ������� ���������� �������������, � ������� ������� �������� ��������������.
Rect Rect::BoundingRect(const Rect& two)
{
	Rect tmp;

	(m_left <= two.m_left) ? tmp.m_left = m_left : tmp.m_left = two.m_left;//��������� ��������

	(m_right >= two.m_right) ? tmp.m_right = m_right : tmp.m_right = two.m_right;

	(m_top <= two.m_top) ? tmp.m_top = m_top : tmp.m_top = two.m_top;

	(m_bottom >= two.m_bottom) ? tmp.m_bottom = m_bottom : tmp.m_bottom = two.m_bottom;

	return tmp;
}

Rect::~Rect()
{
	std::cout << "Now I am in Rect's destructor!" << std::endl;
}

